<template>
  <view class="car-wash-detail">
    <!-- 店铺图片轮播 -->
    <swiper class="swiper" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="500">
      <swiper-item v-for="(img, index) in imgs" :key="index">
        <image class="swiper-img" :src="img"></image>
      </swiper-item>
    </swiper>

    <!-- 店铺基本信息 -->
    <view class="shop-info">
      <text class="shop-name">{{ shopName }}</text>
      <view class="rating-sales">
        <view class="rating">
          <text class="star" v-for="(star, starIndex) in 5" :key="starIndex">
            {{ starIndex < rating ? '★' : '☆' }}
          </text>
          <text class="score">{{ rating }}分</text>
        </view>
        <text class="sales">销量：{{ sales }}</text>
      </view>
      <text class="business-hours">营业时间：{{ businessHours }}</text>
      <view class="address01">
		  <text class="address">
		    {{ address }}
		  </text>
		   <image class="location-icon" src="/static/纸飞机.png"></image>
	  </view>
    </view>

    <!-- 服务内容 -->
    <view class="service-section">
      <text class="section-title">服务</text>
      <view class="service-item">
        <checkbox class="service-checkbox" :checked="false"></checkbox>
        <text class="service-name">精洗</text>
        <text class="price">¥{{ price }}</text>
        <text class="original-price">¥{{ originalPrice }}</text>
      </view>
      <text class="service-desc">{{ serviceDesc }}</text>
    </view>

    <!-- 服务评价 -->
    <!-- 服务评价 -->
    <view class="service-section">
      <text class="section-title">服务评价</text>
      <!-- 循环遍历多条评价 -->
      <view class="evaluation-item" v-for="(item, index) in evaluations" :key="index">
        <image class="avatar" :src="item.avatar"></image>
        <view class="evaluation-info">
          <view class="user-info">
            <text class="user-name">{{ item.userName }}</text>
            <text class="evaluate-time">{{ item.evaluateTime }}</text>
          </view>
          <view class="star-rating">
            <text class="star" v-for="(star, starIndex) in 5" :key="starIndex">
              {{ starIndex < item.rating ? '★' : '☆' }}
            </text>
          </view>
          <text class="evaluation-text">{{ item.evaluationText }}</text>
          <view class="evaluation-imgs">
            <image class="evaluation-img" :src="img" v-for="(img, imgIndex) in item.imgs" :key="imgIndex"></image>
          </view>
        </view>
      </view>
    </view>

    <!-- 底部立即下单按钮 -->
      <button class="order-btn" @click="handleOrder">立即下单</button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 轮播图图片地址，实际可从接口获取
      imgs: [
        "/static/car-wash1.jpg",
        "/static/car-wash2.jpg",
        "/static/car-wash3.jpg",
        "/static/car-wash4.jpg",
        "/static/car-wash5.jpg"
      ],
      shopName: "小王汽车美容店",
      rating: 3, // 店铺评分
      sales: 322, // 销量
      businessHours: "周一至周五 09:00-22:00",
      address: "山阳区人民中路32号",
      price: 199, // 现价
      originalPrice: 299, // 原价
      serviceDesc: "服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍服务介绍",
      evaluations: [
            {
              avatar: "/static/avatar.jpg",
              userName: "李**",
              evaluateTime: "2022-09-10",
              rating: 3, 
              evaluationText: "服务评价内容服务评价内容服务评价内容服务评价内容服务评价内容服务评价内容服务评价内容服务评价内容",
              imgs: ["/static/eval1.jpg", "/static/eval2.jpg"]
            },
            {
              avatar: "/static/avatar2.jpg",
              userName: "张**",
              evaluateTime: "2022-09-12",
              rating: 4, 
              evaluationText: "第二次来啦，服务依旧很专业，洗完车跟新的一样～",
              imgs: ["/static/eval3.jpg", "/static/eval4.jpg"]
            },
            {
              avatar: "/static/avatar3.jpg",
              userName: "王**",
              evaluateTime: "2022-09-15",
              rating: 5, 
              evaluationText: "强烈推荐！细节处理特别到位，价格也合理",
              imgs: ["/static/eval5.jpg"]
            }
          ]
    };
  },
  methods: {
    handleOrder() {
      // 处理立即下单逻辑，比如跳转到下单页面、调用接口等
      uni.showToast({
        title: "正在下单...",
        icon: "loading"
      });
	  uni.navigateTo({
	    url: '/pages/order-confirm/order-confirm'
	  })
      // 这里可补充实际下单逻辑，如 uni.navigateTo 跳转到确认订单页等
    }
  }
};
</script>

<style scoped>
.car-wash-detail {
  padding: 15rpx;
  background-color: #fff;
}

/* 轮播图样式 */
.swiper {
  width: 100%;
  height: 400rpx;
}
.swiper-img {
  width: 100%;
  height: 100%;
}

/* 店铺信息样式 */
.shop-info {
  margin-top: 20rpx;
}
.shop-name {
  font-size: 32rpx;
  font-weight: bold;
}
.rating-sales {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10rpx;
}
.rating {
  display: flex;
  align-items: center;
}
.star {
  color: #ffd100;
  font-size: 24rpx;
  margin-right: 2rpx;
}
.score {
  font-size: 24rpx;
  margin-left: 10rpx;
}
.sales {
  font-size: 24rpx;
}
.business-hours,
.address {
  font-size: 24rpx;
  margin-top: 10rpx;
  color: #666;
}
.address01{
	display: flex;
	text-align: center;
	height: 28rpx;
}
.location-icon {
  width: 28rpx;
  height: 28rpx;
  margin-top: 20rpx;
  margin-left: 15rpx;
}

/* 服务内容样式 */
.service-section {
  margin-top: 30rpx;
}
.section-title {
  font-size: 28rpx;
  font-weight: bold;
  border-left: 8rpx solid #007aff;
  padding-left: 10rpx;
  margin-bottom: 15rpx;
}
.service-item {
  display: flex;
  align-items: center;
  margin-top: 15rpx;
  margin-bottom: 10rpx;
}
.service-checkbox {
  margin-right: 10rpx;
}
.service-name {
  font-size: 26rpx;
}
.price {
  color: #ff0000;
  font-size: 26rpx;
  margin-left: 20rpx;
}
.original-price {
  text-decoration: line-through;
  color: #999;
  font-size: 24rpx;
  margin-left: 10rpx;
}
.service-desc {
  font-size: 24rpx;
  color: #666;
  line-height: 40rpx;
}

/* 服务评价样式 */
.evaluation-item {
  display: flex;
  margin-top: 20rpx;
  /* 新增：每条评价底部留白 */
  margin-bottom: 30rpx; 
  padding-bottom: 20rpx;
  border-bottom: 1px solid #f5f5f5; /* 可选：加分割线区分评价 */
}
.avatar {
  background-color: red;
  width: 80rpx;
  height: 80rpx;
  border-radius: 50%;
  margin-right: 15rpx;
}
.evaluation-info {
  flex: 1;
}
.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10rpx;
}
.user-name {
  font-size: 26rpx;
  font-weight: bold;
}
.evaluate-time {
  font-size: 22rpx;
  color: #999;
}
.star-rating {
  margin-bottom: 10rpx;
}
.evaluation-text {
  font-size: 24rpx;
  color: #333;
  line-height: 36rpx;
  margin-bottom: 10rpx;
}
.evaluation-imgs {
  display: flex;
  flex-wrap: wrap;
}
.evaluation-img {
  background-color: red;
  width: 120rpx;
  height: 120rpx;
  margin-right: 10rpx;
  margin-bottom: 10rpx;
  border-radius: 10rpx;
}

/* 底部按钮样式 */
.bottom-btn {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #fff;
  padding: 20rpx;
  box-sizing: border-box;
}
.order-btn {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  background-color: #ff0000;
  color: #fff;
  font-size: 32rpx;
  border-radius: 10rpx;
}
</style>
